<template>

  <div>
    <router-link to="/index"></router-link>
    <div id="box">
      <v-header title="手机登录"></v-header>

      <!-- 中间部分 -->
      <div id="center1">
        <img :src='require("../../assets/images/logo1.png")' alt="" />
          <div>
            <input type="text" name="" id="" placeholder="手机号" v-model="user.phone"/>
          </div>
          <div class="yzm">
            <input type="text" name="" id="" placeholder="密码" v-model="user.password"/>
          </div>
          <input type="submit" value="登 录" class="in1" @click="login"/>
 
      </div>

      <!-- 底部内容 -->
      <div id="bottom1">
        <p></p>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data(){
    return{
      user:{
        phone:"",
        password:""
      }
    }
  },
  methods:{
    login(){
      axios({
        url: "/api/login",
        method: "post",
        data: this.user,
      }).then((res) => {
        if (res.data.code == 200) {
          localStorage.setItem("userInfo", JSON.stringify(res.data.list));
          this.$router.push("/index");
        } else {
          alert(res.data.msg);
        }
      })
    }
  }
};
</script>

<style scoped>
html,
body,
#box {
  height: 100%;
}
#box {
  max-width: 7.5rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/*中间部分*/
#center1 {
  width: 7.12rem;
  background: #fff;
  flex: 1;
  margin: 0.2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 2.5rem;
}
#center1 img {
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
  width: 3.64rem;
}
#center1 input {
  width: 6.12rem;
  height: 0.84rem;
  border: none;
  color: #8b8b8b;
}
#center1 form {
  text-align: center;
}
#center1 form div {
  border-bottom: 1px solid #f7f7f7;
  width: 6.1rem;
}
#center1 form .yzm {
  display: flex;
  justify-content: space-between;
}
#center1 form .yzm span {
  background: #ccc;
  color: #e9e9e9;
  width: 1.7rem;
  height: 0.25rem;
  line-height: 0.25rem;
  padding: 0.2rem 0.2rem;
  margin-top: 0.1rem;
  position: absolute;
  right: 0.7rem;
}
#center1 .in1 {
  margin-top: 0.4rem;
  color: #fff;
  background: #ff4400;
  border: none;
    margin-bottom: 10px;
}
/*底部部分*/
#bottom1 {
  position: fixed;
  transform: translate(-50%,-50%);
  left: 50%;
  bottom: 0.1rem;
  
}
#bottom1 p {
  width: 2.68rem;
  height: 0.1rem;
  background: #000;
  border-radius: 0.2rem;
}

</style>